var express = require('express');
var fs = require('fs');
var app = express();

app.get('/logstats', function (req, res) {
	var d = new Date();
	fileName = d.getFullYear() + "_" + d.getMonth() + "_" + d.getDate() + ".txt";
  	var filePath = __dirname + '/dist/P2PHLSPlayer/dist/log/' + fileName;
  	fs.appendFile(filePath, JSON.stringify(req.query) + '\n', function () {
		res.end();
  	});
});

app.get('/chromeless/index.html', function(req, res){
 res.sendfile(__dirname + '/dist/flashChromeless/index.html');
});

app.get('/P2PHLSPlayer/index.html', function(req, res){
 res.sendfile(__dirname + '/dist/P2PHLSPlayer/index.html');
});

app.use('/chromeless', express.static(__dirname + '/dist/flashChromeless'));
app.use('/libs', express.static(__dirname + '/dist/flashChromeless/libs'));
app.use('/playlists', express.static(__dirname + '/dist/flashChromeless/libs/playlists'));
app.use('/P2PHLSPlayer', express.static(__dirname + '/dist/P2PHLSPlayer/dist'));
app.use('/assets', express.static(__dirname + '/dist/P2PHLSPlayer/dist/assets'));

app.listen(3000);